<template>
	<view class="container">
		<view class="list">
			<view class="item u-border-bottom" v-for="(item,i) of list" :key="i" @click="goChat(item.id,item.name)">
				<view class="head">
					<!-- <image class="head-img" :src="item.icon"></image> -->
					<u-avatar :src="item.icon" size="96"></u-avatar>
				</view>
				<view class="info">
					<view class="top">
						<view class="left">{{item.name}}</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: []
			}
		},
		created() {
			this.getGroupList()
		},
		methods: {
			async getGroupList() {
				let res = await this.$u.api.communityList()
				if (res != '') {
					this.list = res.data
					let data = this.$utils.reduceData(res.data)
					uni.setStorageSync(this.$config.group_list_key, data);
				}
			},
			goChat(dstId,name) {
				this.$u.route('/pages/message/groupChat/groupChat', {
					dstId: dstId,
					name: name
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.container {
	.list {
		.item {
			display: flex;
			align-items: center;
			padding: 20rpx 32rpx;
			.head {
				position: relative;
				.head-img {
					background: $gg-color;
					width: 96rpx;
					height: 96rpx;
				}

				.red-dot {
					position: absolute;
					left: 68rpx;
					top: -8rpx;
					padding: 2rpx 10rpx;
					background: #ff5d5b;
					border-radius: 18rpx;
					font-size: 24rpx;
					line-height: 32rpx;
					color: #ffffff;
					letter-spacing: -0.41rpx;
				}
			}
			.info {
				margin-left: 32rpx;
				width: 100%;
				.top {
					display: flex;
					justify-content: space-between;
					align-items: center;
					.left {
						font-size: 36rpx;
						color: #272832;
						letter-spacing: -1.23rpx;
						line-height: 50rpx;
					}
					.time {
						font-size: 24rpx;
						color: rgba(39, 40, 50, 0.4);
						letter-spacing: -0.82rpx;
						line-height: 34rpx;
					}
				}
				.bottom {
					font-size: 28rpx;
					color: rgba(39, 40, 50, 0.6);
					letter-spacing: -0.96rpx;
					line-height: 40rpx;
					overflow: hidden;
					text-overflow: ellipsis;
					display: -webkit-box;
					-webkit-line-clamp: 1;
					-webkit-box-orient: vertical;
				}
			}
		}
	}
}
</style>
